package com.itheima.udp;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

public class ReceiveClient {

    public static void main(String[] args) throws IOException {
        //创建对象
        DatagramSocket ds = new DatagramSocket(9999);
        //接受数据
        byte[] bytes = new byte[64*1024];
        DatagramPacket dp = new DatagramPacket(bytes,bytes.length);
        ds.receive(dp);
        //展示数据
        int length = dp.getLength();
        String s = new String(bytes, 0, length);
        System.out.println(s);
        // 释放资源
        ds.close();



    }
}
